# !/bin/bash
#

# Prase info on mkswireless.ini
SSIDLINE=`cat /boot/mkswireless.ini | grep -E 'SSID'`&& echo ${SSIDLINE#*=}
PWDLINE=`cat /boot/mkswireless.ini | grep -E 'PASSWORD'`&& echo ${PWDLINE#*=}

SSID=\"${SSIDLINE#*=}\" && echo ${SSID}
PWD=\"${PWDLINE#*=}\" && echo \"${PWD}\"

# connect wifi

nmcli device wifi list > /boot/wifilist.txt
nmcli device wifi connect $(SSID) password $(PWD)

# Update the wireless configure
# sed -i "s/ssid=.*/ssid="${SSID}"/" /etc/wpa_supplicant/wpa_supplicant.conf 
# sed -i "s/psk=.*/psk="${PWD}"/" /etc/wpa_supplicant/wpa_supplicant.conf

# echo '\n'
# echo 'repaired complete!'

# wpa_supplicant -B -d -i wlan0 -c /etc/wpa_supplicant.conf

# dhclient wlan0

